package com.leecode.string;

/**
 * 两字符相乘,不能转数字操作.
 * return str
 */
public class StrMultiStrMain {
	public static void main(String[] args) {
		char[] add = add(new char[]{'9', '9'}, new char[]{'9', '9'});
		System.out.println(new String(add));
	}

	/**
	 * 我写的是纯字符add,进位显得非常难处理
	 * 网友:char计算,但是用int[]接收结果,最后倒序处理int[]的进位问题99*99=9801
	 *    81 81
	 * 81 81        81 162 81   81 162+8 1      81 170 1        81+17 0 1       98 0 1      秀得头皮以发麻
	 */
	public static String multiply(String num1, String num2) {
		char[] chars1 = num1.toCharArray();
		char[] chars2 = num2.toCharArray();

		char[] result = new char[num1.length() + num2.length()];
		for (int i = chars1.length - 1; i >= 0; i--) {
			for (int j = chars2.length - 1; j >= 0; j--) {
				//确家小数点个数.
				int point=chars1.length-1-i+chars2.length-1-j;
				int temp=(chars1[i] - '0') * (chars2[j] - '0');
				if (temp>=10) {
					int one=temp%10;
					int ten=temp/10;

				}else{
					result[result.length-1-point]=(char)temp;
				}
			}
		}

		return null;
	}

	public static char[] add(char[] source, char[] isadded) {

		return source;
	}
}
